SourceReference.js ➔ ... ➔ it(ꞌCreate with JSONꞌ)   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 20
rs 9.4285
1
var assert = require('chai').assert,
2
    GedcomX = require('../../');
3
4
describe('SourceReference', function(){
5
  
6
  it('Create with JSON', function(){
7
    var ref = GedcomX.SourceReference({
8
      id: 'source-ref',
9
      description: 'http://some/uri',
10
      attribution: {
11
        created: 11121211112
12
      },
13
      qualifiers: [
14
        {
15
          name: 'http://gedcomx.org/CharacterRegion',
16
          value: '37'
17
        } 
18
      ]
19
    });
20
    assert.equal(ref.getId(), 'source-ref');
21
    assert.equal(ref.getDescription(), 'http://some/uri');
22
    assert.equal(ref.getAttribution().getCreated().getTime(), 11121211112);
23
    assert.equal(ref.getQualifiers().length, 1);
24
    assert.equal(ref.getQualifiers()[0].getName(), 'http://gedcomx.org/CharacterRegion');
25
  });
26
  
27
  it('Build', function(){
28
    var ref = GedcomX.SourceReference()
29
      .setId('source-ref')
30
      .setDescription('http://some/uri')
31
      .setAttribution({ created: 11121211112 })
32
      .addQualifier(
33
        GedcomX.Qualifier().setName('http://gedcomx.org/CharacterRegion').setValue(37)
34
      );
35
    assert.equal(ref.getId(), 'source-ref');
36
    assert.equal(ref.getDescription(), 'http://some/uri');
37
    assert.equal(ref.getAttribution().getCreated().getTime(), 11121211112);
38
    assert.equal(ref.getQualifiers().length, 1);
39
    assert.equal(ref.getQualifiers()[0].getName(), 'http://gedcomx.org/CharacterRegion');
40
  });
41
  
42
  it('toJSON', function(){
43
    var refData = {
44
      id: 'source-ref',
45
      description: 'http://some/uri',
46
      attribution: {
47
        created: 11121211112
48
      },
49
      qualifiers: [
50
        {
51
          name: 'http://gedcomx.org/CharacterRegion',
52
          value: '37'
53
        } 
54
      ]
55
    },
56
    ref = GedcomX.SourceReference(refData);
57
    assert.deepEqual(ref.toJSON(), refData);
58
  });
59
  
60
});